package com.xinqing.bigdata.flink.table.demo;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.types.Row;

/**
 * @Author:CHQ
 * @Date:2021/5/26 13:55
 * @Description
 */
public class Test1 {
    public static void main(String args[]) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(new Configuration());
        StreamTableEnvironment tableEnvironment = StreamTableEnvironment.create(env);

        DataStreamSource<String> stringDataStreamSource = env.fromElements("Jay", "Chq", "Alice");

        tableEnvironment.createTemporaryView("name", tableEnvironment.fromDataStream(stringDataStreamSource));

        DataStream<Row> rowDataStream = tableEnvironment.toDataStream(tableEnvironment.sqlQuery("select upper(f0) from name"));

        rowDataStream.print();

        env.execute();

    }
}
